package com.apes.autoparts.supplier.todo;

import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface SupplierPlatformTodoRepository extends CustomRepository<SupplierPlatformTodo, String> {

    /**
     *
     * @return
     */
    @Query(value = " SELECT a.source " +
            "   FROM SupplierPlatformTodo a " +
            "  WHERE a.id  not in (:ids) AND a.source in (:sources) AND a.state in('waitingConfirm','waitingResolve')")
    List<String> findTodoByPage(@Param("ids") List<String> ids, @Param("sources") List<String> sources);

    @Query(value = " SELECT a.source,a.id " +
            "   FROM SupplierPlatformTodo a " +
            "  WHERE a.id  not in (:ids) AND a.source in (:sources) AND a.state = 'waitingResolve' and a.supplierPlatformItem.id = :supplierPlatformItem")
    List<String> findTodoByWaitingResolve(@Param("ids") List<String> ids, @Param("sources") List<String> sources, String supplierPlatformItem);

    @Query(value = " SELECT a.source " +
            "   FROM SupplierPlatformTodo a " +
            "  WHERE a.id  not in (:ids) AND a.source in (:sources) AND a.state ='waitingConfirm' and a.supplierPlatformItem.id = :supplierPlatformItem")
    List<String> findTodoByWaitingConfirm(@Param("ids") List<String> ids, @Param("sources") List<String> sources, String supplierPlatformItem);
}
